package com.fuershiye.woman.monitor.utils;

import com.fuershiye.woman.monitor.constants.Rules;

public class RuleNeiMengUtil {

	/**
	 * 获取上报数据应该属于
	 * last2YearValue==null时，不会返回20
	 * 
	 * @param ruleCode
	 * @param nowValue
	 * @param lastYearValue
	 * @return
	 *
	 */
		public static Integer getShowLevel(Integer ruleCode, Double nowValue, Double lastYearValue, Double aimValue) {
		
			if(ruleCode==null){
				ruleCode=0;
			}
			Rules rule = Rules.getByCode(ruleCode);
			if(rule==null){
				return null;
			}
		//  目前只考虑，2种无目标值：YEAR_UP(1, "逐年上升"),YEAR_DOWN(2, "逐年下降")，EXSIT_VALUE(3, "存在一定比例"),
		//  目前只考虑，5种有目标值：AIM_UP(4, "大于目标值"),AIM_EQUAL(5, "等于目标值"),AIM_DOWN(6, "小于目标值"),
		// 							 AIM_EQUAL_UP(7, "大于等于目标值"),AIM_EQUAL_DOWN(8, "小于等于目标值"),
		switch (rule) {
			// YEAR_UP(1, "逐年上升"),
			case YEAR_UP:
				return RuleUtil.getUp(nowValue, lastYearValue);

				// YEAR_DOWN(2, "逐年下降"),
			case YEAR_DOWN:
				return RuleUtil.getDown(nowValue, lastYearValue);

				// EXSIT_VALUE(3, "存在一定比例"),
			case EXSIT_VALUE:
				return RuleUtil.getExsit(nowValue);
				
				// AIM_UP(4, "大于目标值"),
			case AIM_UP:
				return RuleUtil.getAimUp(nowValue, aimValue);
				
				//	AIM_EQUAL(5, "等于目标值"),
			case AIM_EQUAL:
				return RuleUtil.getAimEqual(nowValue, aimValue);
				
				// AIM_DOWN(6, "小于目标值"),
			case AIM_DOWN:
				return RuleUtil.getAimDown(nowValue, aimValue);
				
				// AIM_EQUAL_UP(7, "大于等于目标值"),
			case AIM_EQUAL_UP:
				return RuleUtil.getAimUpEqual(nowValue, aimValue);
				
				// AIM_EQUAL_DOWN(8, "小于等于目标值"),
			case AIM_EQUAL_DOWN:
				return RuleUtil.getAimDownEqual(nowValue, aimValue);
				
	//		// AIM_BETWEEN(9, "目标值在区间内"),
	//		case AIM_BETWEEN:
	//			return ShowLevelUtilString.getUpEqualLevel(nowValue, aimValue);
				
				// RATE_UP(10, "增长率大于目标值"),
//			case RATE_UP:
//				return getUpLevel(
//						RuleBaseUtil.getRate(nowValue, lastYearValue),
//						aimValue);
//
//				// RATE_EQUAL(11, "增长率等于目标值"),
//			case RATE_EQUAL:
//				return getEqualLevel(
//						RuleBaseUtil.getRate(nowValue, lastYearValue),
//						aimValue);
//
//				// RATE_DOWN(12, "增长率小于目标值"),
//			case RATE_DOWN:
//				return getDownLevel(
//						RuleBaseUtil.getRate(nowValue, lastYearValue),
//						aimValue);
//
//				// RATE_EQUAL_UP(13, "增长率大于等于目标值"),
//			case RATE_EQUAL_UP:
//				return getUpEqualLevel(
//						RuleBaseUtil.getRate(nowValue, lastYearValue),
//						aimValue);
//
//				// RATE_EQUAL_DOWN(14, "增长率小于等于目标值"),
//			case RATE_EQUAL_DOWN:
//				return getDownEqualLevel(
//						RuleBaseUtil.getRate(nowValue, lastYearValue),
//						aimValue);
//
	//		// RATE_BETWEEN_UP(15, "增长率在区间内上升"),
	//		case RATE_BETWEEN_UP:
	//			return getDownEqualLevel(
	//					RuleBaseUtil.getRate(nowValue, lastYearValue),
	//					aimValue);
	//
	//		// RATE_BETWEEN_DOWN(16, "增长率在区间内下降"),
	//		case RATE_BETWEEN_DOWN:
	//			return getDownEqualLevel(
	//					RuleBaseUtil.getRate(nowValue, lastYearValue),
	//					aimValue);
				
				// PARENT_UP(17, "实际值大于父级指标"),
//			case PARENT_UP:
//				return getUpLevel(nowValue, parentValue);
//
//				// PARENT_EQUAL(18, "实际值等于父级指标"),
//			case PARENT_EQUAL:
//				return getEqualLevel(nowValue, parentValue);
//
//				// PARENT_DOWN(19, "实际值小于父级指标"),
//			case PARENT_DOWN:
//				return getDownLevel(nowValue, parentValue);
//
//				// PARENT_EQUAL_UP(20, "实际值大于等于父级指标"),
//			case PARENT_EQUAL_UP:
//				return getUpEqualLevel(nowValue, parentValue);
//
//				// PARENT_EQUAL_DOWN(21, "实际值小于等于父级指标"),
//			case PARENT_EQUAL_DOWN:
//				return getDownEqualLevel(nowValue, parentValue);
//
	//		// PARENT_BETWEEN_UP(22, "实际值大于父级指标在区间内"),
	//		case PARENT_BETWEEN_UP:
	//			return getDownEqualLevel(nowValue, parentValue);
	//
	//		// PARENT_BETWEEN_DOWN(23, "实际值小于父级指标在区间内"),
	//		case PARENT_BETWEEN_DOWN:
	//			return getDownEqualLevel(nowValue, parentValue);
				
				// PARENT_RATE_UP(24, "占父级指标百分比大于目标值"),
//			case PARENT_RATE_UP:
//				return getUpLevel(
//						RuleBaseUtil.getRate(nowValue, parentValue),
//						aimValue);
//
//				// PARENT_RATE_EQUAL(25, "占父级指标百分比等于目标值"),
//			case PARENT_RATE_EQUAL:
//				return getEqualLevel(
//						RuleBaseUtil.getRate(nowValue, parentValue),
//						aimValue);
//
//				// PARENT_RATE_DOWN(26, "占父级指标百分比小于目标值"),
//			case PARENT_RATE_DOWN:
//				return getDownLevel(
//						RuleBaseUtil.getRate(nowValue, parentValue),
//						aimValue);
//
//				// PARENT_RATE_EQUAL_UP(27, "占父指标百分比大于等于目标值"),
//			case PARENT_RATE_EQUAL_UP:
//				return getUpEqualLevel(
//						RuleBaseUtil.getRate(nowValue, parentValue),
//						aimValue);
//
//				// PARENT_RATE_EQUAL_DOWN(28, "占父指标百分比小于等于目标值"),
//			case PARENT_RATE_EQUAL_DOWN:
//				return getDownEqualLevel(
//						RuleBaseUtil.getRate(nowValue, parentValue),
//						aimValue);
//
	//		// PARENT_RATE_BETWEEN_UP(29, "占父指标百分比大于目标值在某区间内"),
	//		case PARENT_RATE_BETWEEN_UP:
	//			return getDownEqualLevel(
	//					getRate(nowValue, parentValue),
	//					aimValue);
	//
	//		// PARENT_RATE_BETWEEN_DOWN(30, "占父指标百分比小于目标值在某区间内"),
	//		case PARENT_RATE_BETWEEN_DOWN:
	//			return getDownEqualLevel(
	//					getRate(nowValue, parentValue),
	//					aimValue);
			default:
				return null;
		}
	}

	public static void main(String[] args) throws Exception {
//		System.out.println(RuleBaseUtil.getRate(130d, 71d));
	}

}